using ASP;
using HoWave.Common;
using HoWave.Data.Bll;
using HoWave.Web;
using HoWave.Web.Shop.Member;
using System;
using System.Data;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Member_JXC_StockInfoOrderSelect : Member, IRequiresSessionState
{
	private string linkHead = "";
	private string showProType = "";
	private string proTypeWhere = "";
	protected ScriptManager sm;
	protected Literal ltrProType;
	protected GridView GridView1;
	protected Literal ltrPagePanel;
	protected UpdatePanel upGv;
	protected HtmlForm form1;
	public new string ShowProType
	{
		get
		{
			if (base.Request.QueryString["showProType"] != null)
			{
				this.showProType = base.Request.QueryString["showProType"].ToString();
			}
			return this.showProType;
		}
	}
	public string ProTypeWhere
	{
		get
		{
			if (!string.IsNullOrEmpty(this.ShowProType))
			{
				string text = this.ShowProType;
				if (text != null)
				{
					if (text == "1")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType1") + "——";
						goto IL_14A;
					}
					if (text == "2")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType2") + "——";
						goto IL_14A;
					}
					if (text == "3")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType3") + "——";
						goto IL_14A;
					}
					if (text == "4")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType4") + "——";
						goto IL_14A;
					}
					if (text == "5")
					{
						this.ltrProType.Text = Language.Get("Shop/Product/ProductType5") + "——";
						this.proTypeWhere = " and O.TradeType=5 ";
						goto IL_14A;
					}
				}
				this.proTypeWhere = " and O.TradeType<>5 ";
				IL_14A:;
			}
			else
			{
				this.proTypeWhere = " and O.TradeType<>5 ";
			}
			return this.proTypeWhere;
		}
	}
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (!base.IsPostBack)
		{
			if (!base.OwnerPowerFinancemanage(base.user.UserID))
			{
				this.Page.ClientScript.RegisterStartupScript(base.GetType(), "", "<script>alert('" + Language.GetMemberMsg("Common/RightErr", new string[0]) + "');window.close();</script>");
			}
			this.BindList();
		}
	}
	protected void BindList()
	{
		string text = this.QuestString();
		Shop_Order shop_Order = new Shop_Order(this.conn);
		CurrPageLinks currPageLinks = new CurrPageLinks();
		int num = this.GridView1.PageIndex;
		if (Fetch.Get("pageindex") != null)
		{
			num = Convert.ToInt32(Fetch.GetID("pageindex").ToString());
			if (num == 0)
			{
				num = 1;
			}
		}
		string text2 = string.Concat(new object[]
		{
			" from HLJXC_StockInfoOrder as sio,HLShop_Order as o where sio.OrderID=o.OrderFormID and o.SalerID=",
			base.user.UserID,
			" and sio.InfoOrderID not in (select StockOrderID from HLJXC_AccountAoucher where OwnerID=",
			base.user.UserID,
			") ",
			text,
			" "
		});
		string str = "Order By O.OrderFormID Desc";
		int pageSize = this.GridView1.PageSize;
		ClientByPage clientByPage = new ClientByPage();
		int listCount = clientByPage.GetListCount("select count(*)" + text2);
		string url = "StockOrderSaleSelect.aspx?1=1" + this.linkHead + "&pageindex";
		int startIndex = (num - 1) * pageSize + 1;
		int endIndex = num * pageSize;
		string str2 = "ROW_NUMBER() OVER (" + str + ") as row,sio.InfoOrderID,sio.InfoNumber,sio.CreateDate,sio.Fee,sio.ReceiptMoney,sio.AlreadyReceiptMoney,MoneyGoods,Deliver_TotalPrice,Invoice_TotalPrice,MoneyTotal,o.TradeType ";
		string strSQL = "select " + str2 + text2;
		DataTable listPage = clientByPage.GetListPage(strSQL, "row", startIndex, endIndex);
		this.GridView1.DataSource = listPage;
		this.GridView1.DataBind();
		if (listPage.Rows.Count > 0)
		{
			this.ltrPagePanel.Text = currPageLinks.CurrPageLink(num, pageSize, listCount, "条记录&nbsp;每页" + pageSize + "条记录&nbsp;", url);
		}
	}
	protected string QuestString()
	{
		return "and ((O.TradeType=2 and DateDiff(s,UpdateTime,getdate())>=0 and (AuctionEndPrice in(select max(AuctionEndPrice) from HLShop_Order as a,HLShop_OrderItem as b where a.OrderFormID=b.OrderFormID Group by b.ProductID))) or (O.TradeType=3 and O.Teameffect=1) or (O.TradeType<>2 and O.TradeType<>3)) " + this.ProTypeWhere;
	}
	protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
	{
		this.GridView1.PageIndex = e.NewPageIndex;
		this.BindList();
	}
}
